<?php
	class tag{
		function _arclist($attr, $content) {
        //栏目CID
        //1 调用标签设置了cid属性
        //2 取$_GET['cid']
        //3 NULL 会取得所有栏目里面的文章
        $cid = isset($attr['cid'])?$attr['cid']:
            (isset($_GET['cid'])?'$_GET[cid]':null);
        //显示文章条数据
        $row = isset($attr['row'])?$attr['row']:10;
        //排序方式
        $type = isset($attr['type'])?$attr['type']:null;
        $where ='';
        if($cid){
            $where = 'cid ='.$cid.' AND shenhe='."'1'";
        }
        //排序
        switch($type){
            case 'hot':
                $order = "click desc";
                break;
            default:
                $order = "aid desc";
        }
        $str='';
        $str.='<?php $db = M("arc");';
        $str.='$result= $db->where("'.$where.'")->field("aid,title,addtime,click,thumbimg")->limit('.$row.')->order("'.$order.'")->all();';
        $str.='foreach($result as $field):
            $field["img"] = $field["thumbimg"];
            $field["url"]=get_url($field);
        ?>';
           $str.=$content;
        $str.='<?php endforeach;?>';
        return $str;
    }

    
}
?>

